<!-- eslint-disable no-empty-source -->
<script setup lang="ts">
import { useRecord } from "./utils/recordhook";
import { PureTableBar } from "@/components/RePureTableBar";

import { deviceDetection } from "@pureadmin/utils";

defineOptions({
  name: "MonitorTaskRecord"
});

// 接受参数 id
const props = defineProps<{
  id: string;
}>();

const {
  isShow,
  loading,
  columns,
  rowStyle,
  dataList,
  pagination,
  handleSizeChange,
  handleCurrentChange,
  handleSelectionChange
} = useRecord(props.id);
</script>

<template>
  <div class="main">
    <PureTableBar
      :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
      style="transition: width 220ms cubic-bezier(0.4, 0, 0.2, 1)"
      title="任务记录"
      :columns="columns"
    >
      <template v-slot="{ size, dynamicColumns }">
        <pure-table
          ref="tableRef"
          align-whole="center"
          showOverflowTooltip
          table-layout="auto"
          :loading="loading"
          :size="size"
          adaptive
          :row-style="rowStyle"
          :adaptiveConfig="{ offsetBottom: 108 }"
          :data="dataList"
          :columns="dynamicColumns"
          :pagination="pagination"
          :paginationSmall="size === 'small' ? true : false"
          :header-cell-style="{
            background: 'var(--el-fill-color-light)',
            color: 'var(--el-text-color-primary)'
          }"
          @selection-change="handleSelectionChange"
          @page-size-change="handleSizeChange"
          @page-current-change="handleCurrentChange"
        />
      </template>
    </PureTableBar>
  </div>
</template>
